<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>菜鸟教程(runoob.com)</title>
		<style>
			.username {
				height: 30px;
				width: 80%;
			}

			.pwd {
				height: 30px;
				width: 80%;
			}
		</style>
	</head>
	<body>
		<input id="username" class="username" type="text" placeholder="请输入用户名" /><br>
		<input id="pwd" class="pwd" type="password" placeholder="请输入密码"/><br>
		<button onclick="login()">登录</button>
		<script type="text/javascript">
			function login() {
				var a = "test";
				var password = document.getElementById("pwd").value
				alert("password:" + password)
				if (password == "as222") {
					alert("进入if的password:" + password)
					location.href = "index.html";
					// 存储密码
					localStorage.setItem("userInfo",password)
					// 测试取出密码
					var userInfo = localStorage.getItem("userInfo")
					console.log("userInfo=" + userInfo)
				} else {
					alert("密码错误！！")
					return false;
				}
			}
		</script>
	</body>
</html>
